﻿namespace Pathfinder.Base.Utilities
{
    using System;
    using System.Collections.Generic;

    public static class IEnumerableExtensions
    {
        /// <summary>
        /// Searches a string enumerable for a specific item.
        /// </summary>
        /// <param name="self">List to search.</param>
        /// <param name="searchString">String to search.</param>
        /// <returns>True if feat was found</returns>
        /// <exception cref="ArgumentNullException">Thrown if self or searchString is null.</exception>
        public static bool HasString(this IEnumerable<string> self, string searchString)
        {
            if (self == null) throw new ArgumentNullException("self");
            if (searchString == null) throw new ArgumentNullException("searchString");

            foreach (string item in self)
            {
                if (item.Trim().Equals(searchString, StringComparison.InvariantCultureIgnoreCase))
                {
                    return true;
                }
            }
            return false;
        }
    }
}
